﻿//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NetCMS.Content;

public partial class manage_channel_style_classadd : NetCMS.Web.UI.ManagePage
{
    Channel rd = new Channel();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (SiteID != "0")
            {
                PageError("分站没权限操作", "javascript:history.back();", true);
            }
            copyright.InnerHtml = CopyRight;
            string ChID = Request.QueryString["ChID"];
            string Action = Request.QueryString["Action"];
            if (ChID != null && ChID != string.Empty)
            {
                if (Action != null && Action != string.Empty)
                {
                    int id = int.Parse(Request.QueryString["id"]);
                    IDataReader dr = rd.GetStyleClassInfo(id, int.Parse(ChID.ToString()));
                    if (dr.Read())
                    {
                        this.cName.Text = dr["cName"].ToString();
                    }
                    dr.Close();
                }
            }
            else
            {
                PageError("错误的频道参数", "javascript:history.back();", true);
            }
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string cName = this.cName.Text;
            int ChID = int.Parse(Request.QueryString["ChID"]);
            int ID = 0;
            if (Request.QueryString["Action"] != string.Empty && Request.QueryString["Action"] != null)
            {
                ID = int.Parse(Request.QueryString["ID"]);
            }
            if (rd.GetStyleClassRecord(cName, ID, ChID) > 0)
            {
                PageError("栏目名称重复", "javascript:history.back();", true);
            }
            if (ID != 0)
            {
                //更新
                rd.UpdateStyleClassContent(ID, ChID, cName);
                PageRight("更新样式栏目成功", "style_classlist.aspx?ChID=" + ChID + "", true);
            }
            else
            {
                //插入
                rd.InsertStyleClassContent(ID, ChID, cName);
                PageRight("插入样式栏目成功", "style_classlist.aspx?ChID=" + ChID + "", true);
            }
        }
    }
}
